#!/bin/bash

# startFileServer.sh
imageName="inthbl/file_server"


BinHome="/opt/server.lan"
MntHome="/mnt/server.lan"
TmpHome="/tmp/server.lan"




Xprefix="/file/"
startContainer(){
    if [ $(docker ps -a -f "name=^$containerName$" | wc -l) -gt 1 ];then
        docker start $containerName
    else
    
        portArgs=" -p $port:8080"
        volumeArgs=" -v $dir:/data"
        if [ -n "$innerDir" ];then
            # for inner softlinks
            volumeArgs="$volumeArgs -v $innerDir:$innerDir"
        fi
        docker run  --pull=always -d --name="$containerName"  \
            $portArgs \
            $volumeArgs \
            -e URLPREFIX=$prefix \
            $imageName 
    fi

}


# 48080
containerName="fileserver_wan"
Xport="48080"
# Attension : softlink in Xdir can't read in Docker container!!!!
Xdir="${MntHome}/data/dataStorage/server.lan/share/"

port="$Xport"
dir="$Xdir"
innerDir="/mnt/server.lan/data/dataStorage/server.lan/all_kinds/"
prefix="$Xprefix"
startContainer


##alist
# docker run -d --restart=always --name="containerName" \
#     -v $Xdir:/opt/alist/data \
#     -v /mnt/server.lan/data/dataStorage/server.lan/all_kinds/:/mnt/server.lan/data/dataStorage/server.lan/all_kinds \
#     -p $Xport:5244  \
#     xhofe/alist:latest

# #


